home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0046_SoundBlaster Detect.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  99 lines

  1. {
  2.  
  3. PB> It's me again.  I need code to detect a SB/SB Compat.  card.  I have
  4. PB> code which will detect the port, but I also need a way of detecting the
  5. PB> SB's IRQ and DMA channel.  Is there any such code available?
  6.  
  7. This code was just posted about 2 weeks ago (I believe)... }
  8.  
  9.  
  10. Program DetectSoundBlaster;
  11.  
  12. Uses DOS, CRT;
  13.  
  14. Function hex(a : Word; b : Byte) : String;
  15. Const digit : Array[$0..$F] Of Char = '0123456789ABCDEF';
  16. Var i : Byte;
  17.   xstring : String;
  18. Begin
  19.   xstring:='';
  20.   For i:=1 To b Do
  21.   Begin
  22.     Insert(digit[a And $000F], xstring, 1);
  23.     a:=a ShR 4
  24.   End;
  25.   hex:=xstring
  26. End; {hex}
  27.  
  28. Procedure SoundPort;
  29. Var xbyte1, xbyte2, xbyte3, xbyte4: Byte;
  30.   xword, xword1, xword2, temp, sbport: Word;
  31.   sbfound, portok: Boolean;
  32.  
  33. Begin
  34.   ClrScr;
  35.   Write('Sound Blaster: ');
  36.   sbfound:=False;
  37.   xbyte1:=1;
  38.   While (xbyte1 < 7) And (Not sbfound) Do
  39.   Begin
  40.     sbport:=$200 + ($10 * xbyte1);
  41.     xword1:=0;
  42.     portok:=False;
  43.     While (xword1 < $201) And (Not portok) Do
  44.     Begin
  45.       If (Port[sbport + $0C] And $80) = 0 Then
  46.         portok:=True;
  47.       Inc(xword1)
  48.     End;
  49.     If portok Then
  50.     Begin
  51.       xbyte3:=Port[sbport + $0C];
  52.       Port[sbport + $0C]:=$D3;
  53.       For xword2:=1 To $1000 Do {nothing};
  54.       xbyte4:=Port[sbport + 6];
  55.       Port[sbport + 6]:=1;
  56.       xbyte2:=Port[sbport + 6];
  57.       xbyte2:=Port[sbport + 6];
  58.       xbyte2:=Port[sbport + 6];
  59.       xbyte2:=Port[sbport + 6];
  60.       Port[sbport + 6]:=0;
  61.       xbyte2:=0;
  62.       Repeat
  63.         xword1:=0;
  64.         portok:=False;
  65.         While (xword1 < $201) And (Not portok) Do
  66.         Begin
  67.           If (Port[sbport + $0E] And $80) = $80 Then
  68.             portok:=True;
  69.           Inc(xword1)
  70.         End;
  71.         If portok Then
  72.           If Port[sbport + $0A] = $AA Then
  73.             sbfound:=True;
  74.         Inc(xbyte2);
  75.       Until (xbyte2 = $10) Or (portok);
  76.       If Not portok Then
  77.       Begin
  78.         Port[sbport + $0C]:=xbyte3;
  79.         Port[sbport + 6]:=xbyte4;
  80.       End;
  81.     End;
  82.     If sbfound Then
  83.     Begin
  84.       Write('Yes');
  85.       Write(' Port: ');
  86.       Write('$', Hex(sbport, 3));
  87.     End
  88.     Else
  89.       Inc(xbyte1);
  90.   End;
  91.   If Not sbfound Then
  92.     Write('No');
  93. End;{soundport}
  94.  
  95. Begin
  96.   SoundPort;
  97. End.
  98.  
  99.